package com.example.listossimage.vo;


import lombok.Data;

import java.io.Serializable;

@Data
public class ResponseVo implements Serializable {
    private int result = ResponseErrCode.OK;
    private String message;
    private String redirect;
    private Object data;

    public ResponseVo() {
        message = "OK";
    }

    public static ResponseVo newInstanceErr(int code, String message) {
        ResponseVo vo = new ResponseVo();
        vo.result = code;
        vo.message = message;
        return vo;
    }

    public static ResponseVo newInstanceOK() {
        ResponseVo vo = new ResponseVo();
        vo.message = "OK";
        return vo;
    }

    public static ResponseVo newInstanceErr(String message) {
        ResponseVo vo = new ResponseVo();
        vo.result = ResponseErrCode.OK;
        vo.message = message;
        return vo;
    }

    public static class ResponseErrCode {
        public static final int OK = 200; //OK
        public static final int Redirect = 302; //跳转
        public static final int BusinessErr = 406; //业务不达预期
        public static final int BusinessNoImpl = 407; //该功能未开放
        public static final int ParamErr = 400; //参数校验不过
        public static final int AuthErr = 401; //需要登陆
        public static final int PermissionsErr = 402; //鉴权不过
        public static final int ServerErr = 500; //服务器错误
        /****************************开放API使用************************************/
        public static final int AppIdErr = 408; //appId未授权或假的appId
        public static final int LimitErr = 409; //超出限制
    }
}